//
//  CZHomeTitleButton.swift
//  crkWeibo
//
//  Created by 陈荣科 on 15/12/22.
//  Copyright © 2015年 crk. All rights reserved.
//

import UIKit

class CZHomeTitleButton: UIButton {

    /*
    func setTitleButton(title: String, imageName: String) {
    
       self.setTitle(title, forState: UIControlState.Normal)
        setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        sizeToFit()
    }*/

    init(title: String, imageName: String) {
        super.init(frame: CGRectZero)
        
        setTitle(title, forState: UIControlState.Normal)
        setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        sizeToFit()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        
        self.titleLabel?.frame.origin.x = 0
        
        self.imageView?.frame.origin.x = self.titleLabel!.frame.width + 3
    }
    
}
